using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SolutionClone.Model
{
    public class DefaultConverter : IConverter
    {
        #region IConverter Members

        public string FilePath { get; set; }
        public string OldName { get; set; }
        public string NewName { get; set; }

        public void Convert()
        {
            string contents;
            using (StreamReader rdr = new StreamReader(this.FilePath))
            {
                contents = rdr.ReadToEnd();
            }
            contents = contents.Replace(this.OldName, this.NewName);
            File.Delete(this.FilePath);
            using (StreamWriter wrt = new StreamWriter(this.FilePath))
            {
                wrt.Write(contents);
            }
        }

        #endregion
    }
}
